package com.five.years.common;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class PageBean {

    private Integer currentPage =1;

    private Integer pageSize =20;

    public void preparePage() {
        if (currentPage == null || currentPage < 1) {
            currentPage = Constants.Page.DEFAULT_CURRENT_PAGE;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constants.Page.DEFAULT_SIZE;
        } else if (pageSize > Constants.Page.MAX_PAGE_SIZE) {
            pageSize =Constants.Page.MAX_PAGE_SIZE;
        }
    }

    public Integer getCurrentPage() {
        return currentPage==null?1:currentPage;
    }

    public Integer getPageSize() {
        return pageSize==null?20:pageSize;
    }
}
